package com.chant.startFarming.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chant.startFarming.entity.Pens;
import com.chant.startFarming.mapper.PensMapper;
import com.chant.startFarming.service.IPensService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 圈舍表，存储圈舍的基本信息和状态 服务实现类
 * </p>
 *
 * @author chant
 * @since 2025-03-31
 */
@Service
public class PensServiceImpl extends ServiceImpl<PensMapper, Pens> implements IPensService {

    @Override
    public List<Pens> searchPens(String name, Integer pensStatus) {
        QueryWrapper<Pens> queryWrapper = new QueryWrapper<>();
        if (name != null && !name.isEmpty()) {
            queryWrapper.like("name", name);
        }
        if (pensStatus != null) {
            queryWrapper.eq("pens_status", pensStatus);
        }
        return this.list(queryWrapper);
    }

}
